package operation.io01;

import java.io.File;
import java.util.Scanner;

public class Demo01 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入一个文件夹路径:");
        while (true){
            String s = sc.nextLine();
            File file=new File(s);
            if(!file.exists()){
                System.out.println("你输入的路径不存在,请重新输入");
            }else
                if(file.isFile()){
                System.out.println("你输入的文件是路径");
            }else{
                File[] files = file.listFiles();
                if(files!=null){
                    for (File file1 : files) {
                        String name = file1.getName();
                        System.out.println(name);
                        String ss = file1.getAbsolutePath();
                        System.out.println(ss);
                    }
                }
                break;
            }
        }
    }
}
